<!--title-->
<div class="mnav1">
	<div class="m_nav">
		<div class="nav_left">
			<em class="home_icon"><?=$this->sys_name?></em><span>&nbsp;&gt;&nbsp;</span><font><?=$this->title?></font>
		</div>
	</div>
</div>

<div class="content-table">
<div class="content-table-title"><?=$this->title?></div>
<br />
<?php if($this->msg):?>
<div class="replace"><?=$this->msg?></div>
<br />
<?php endif;?>
<div align="center"><a href="/clients/add-owner"><font color="green"><b>【新增乙方单位】</b></font></a></div>
<br />
<table>
  <tr>
    <th>乙方单位</th>
    <th>注册日期</th>
    <th>状态</th>
    <th>操作</th>
  </tr>
  <?php $data = $this->data['current_page_info'];?>
  <?php if($data["owner_name"]):?>
  <?php foreach($data["owner_name"] as $id => $something):?>
  <tr>
    <td><?=$data["owner_name"][$id]?></td>
	<td><?=$data["ctime"][$id]?></td>
	<td><?php if(1==$data["status"][$id]){echo "<font color='green'>正常</font>";}else{echo "<font color='red'>不可用</font>";}?></td>
	<td>
		<?php if("LEVEL-3" == $_SESSION['identity']['level']):?>
			<?php if(0 == $data["status"][$id]):?>
			<button onclick="OwnerOpt(<?=$id?>, 1)">设为可用</button>
			<?php elseif(1 == $data["status"][$id]):?>
			<button onclick="OwnerOpt(<?=$id?>, 0)">设为不可用</button>
			<?php endif;?>
		<?php endif;?>
	</td>
  </tr>
  <?php endforeach;?>
  <?php endif;?>
</table>

<br /><br />
<div align="right"><?=$this->pagination?></div>
<br /><br /><br />

<script>
function OwnerOpt(id, status)
{
	$.ajax({
			type: "post",
			url : "/ajax/owner-opt",
			dataType:'json',
            async:false,
			data: {
					'id':id,
					'status':status
				  },
				success: function(json){
					if(json.result == 1) {
                        window.location.href = "/clients/owners/status/2";
                    }else{
						window.location.href = "/clients/owners/status/3";
					}
			}
		});
}
</script>